<template>
  <div class="item flex-col" @click="handleAlbumClick">
    <img :src="meta.cover" alt="">
    <div class="name flex-1">{{ meta.title }}</div>
  </div>
</template>

<script>
export default {
  name: "Album",
  inject: ["navigateTo"],
  props: {
    type: {
      type: Number, // 0歌单 1专辑
    },
    meta: {  // type, id, cover, title
      type: Object,
      default: () => ({})
    }
  },
  methods: {
    handleAlbumClick() {
      if(this.meta.type===1){
        this.navigateTo(`/songList/${this.meta.id}`)
      }
    }
  }
}
</script>

<style scoped lang="scss">
@import "~@/assets/css/var";

.item {
  user-select: none;
  width: 100px;
  height: 120px;
  float: left;

  img {
    width: 100px;
    height: 100px;
    border-radius: 5px;
  }

  .name {
    width: 100%;
    overflow: hidden;
    line-height: 1.2;
    white-space: nowrap;
    text-overflow: ellipsis;
    margin-top: $ms;
  }
}
</style>
